package com.xhh.nphm.system.service.impl;

import com.xhh.nphm.system.domain.ReplyTemplate;
import com.xhh.nphm.system.mapper.ReplyTemplateDao;
import com.xhh.nphm.system.service.IReplyTemplateService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

@Service
public class ReplyTemplateServiceImpl implements IReplyTemplateService {
    @Autowired
    ReplyTemplateDao replyTemplateDao;

    @Override
    public List<Map> selectTelRnByDeptOrUser(String deptId, String userId) {
        List<Map> telRnList = replyTemplateDao.selectRnByDeptOrUser(deptId, userId, 1);
        telRnList.add(0,replyTemplateDao.selectDefaultRn());
        return telRnList;
    }

    @Override
    public List<Map> selectMailRnByDeptOrUser(String deptId, String userId) {
        List<Map> mailRnList = replyTemplateDao.selectRnByDeptOrUser(deptId, userId, 2);
        mailRnList.add(0,replyTemplateDao.selectDefaultRn());
        return mailRnList;
    }

    @Override
    public ReplyTemplate selectByPkId(Integer pkId) {
        return replyTemplateDao.selectByPkId(pkId);
    }

    @Override
    public List<Map<String, Object>> selectReplyListJsonByDept(String deptId, ReplyTemplate replyTemplate) {
        if(deptId.equals("100")){
            return replyTemplateDao.selectReplyListJson(replyTemplate);
        }
        return replyTemplateDao.selectReplyListJsonByDept(deptId,replyTemplate);
    }

    @Override
    public boolean saveReplyTemplate(ReplyTemplate replyTemplate) {
        return replyTemplateDao.saveReplyTemplate(replyTemplate) > 0;
    }

    @Override
    public boolean updateReplyTemplate(ReplyTemplate replyTemplate) {
        return replyTemplateDao.updateReplyTemplate(replyTemplate) > 0;
    }

    @Override
    public boolean rTempRemove(String pkId) {
        return replyTemplateDao.removeReplyTemplate(Integer.valueOf(pkId)) > 0;
    }
}
